/*test quicksort algorithm 
 */
/*@*/
array[8,int] QuickSort(array[8,int]arr,int iLow,int iHigh)
{
	 int i,j,m,p;
	 i=iLow;
	 j=iHigh;
	 m=(i+j)/2+j%2;
	 while(i<=j)
	 {
		 while(arr[i]<arr[m]&&i<iHigh)
	        	i=i+1;
	 	while(arr[j]>arr[m]&&j>iLow)
		  	j=j-1;
		 	if(i<=j)
		{
	      		p=arr[i];
	        	arr[i]=arr[j];
	        	arr[j]=p;
	      		i=i+1;
	          	j=j-1;
	    	}
	  }
	      
	  if(j>iLow)
	 	 arr=QuickSort(arr,iLow,j);
	  if(i<iHigh)
	          arr=QuickSort(arr,i,iHigh);          
	  return arr;
}

/*@*/
/*@*/
int main()
{
	array [8,int]a;
	int i;
	i=0;
	a[0]=20;
	a[1]=3;
	a[2]=-1;
	a[3]=8;
	a[4]=9;
	a[5]=0;
	a[6]=7;
	a[7]=8;
	while(i<8)
	{
		print(a[i]);
		i=i+1;
	}
	a=QuickSort(a,0,7);
	i = 0;
	while(i<8)
	{
		print(a[i]);
		i=i+1;
	}
	return 0;
}
/*@*/
